package njust.csc.aecore.entity

/**
 * @Author ZhouHang
 * @Date 24/6/7 周五
 */

/**
 * 分析状态记录
 * */
data class AnalysisStatus(
    var existEnvironment: Boolean = true,

    var installStatus: Boolean = true,
    var installStatusReason: InstallStatusReason = InstallStatusReason.UNKNOWN,

    var uninstallStatus: Boolean = true,
    var uninstallStatusReason: DeleteStatusReason = DeleteStatusReason.UNKNOWN,

    var testRunStatus: Boolean = false,

    var captureServiceStatus: Boolean = false,  // 是否开启抓包服务

    var apeStatus: Boolean = false,  // ape 是否执行完毕
)

enum class InstallStatusReason(val statusName: String) {
    SUCCESS("Success"),
    INSTALL_FAILED_ALREADY_EXISTS("[INSTALL_FAILED_ALREADY_EXISTS]"),
    INSTALL_FAILED_INSUFFICIENT_STORAGE("[INSTALL_FAILED_INSUFFICIENT_STORAGE]"),
    INSTALL_FAILED_NO_MATCHING_ABIS("[INSTALL_FAILED_NO_MATCHING_ABIS]"),
    INSTALL_FAILED_OLDER_SDK("[INSTALL_FAILED_OLDER_SDK]"),
    DELETE_FAILED_INTERNAL_ERROR("[DELETE_FAILED_INTERNAL_ERROR]"),
    UNKNOWN("Unknown");

    companion object {
        fun fromString(name: String): InstallStatusReason {
            for (value in entries) {
                if (value.statusName.equals(name, ignoreCase = true)) {
                    return value
                }
            }
            return UNKNOWN
        }
    }
}


enum class DeleteStatusReason(val statusName: String) {
    SUCCESS("Success"),
    DELETE_FAILED_INTERNAL_ERROR("[DELETE_FAILED_INTERNAL_ERROR]"),
    UNKNOWN("Unknown");

    companion object {
        fun fromString(name: String): DeleteStatusReason {
            for (value in entries) {
                if (value.statusName.equals(name, ignoreCase = true)) {
                    return value
                }
            }
            return UNKNOWN
        }
    }
}